package cn.ch.train.business.controller.admin;

import cn.ch.train.common.context.LoginMemberContext;
import cn.ch.train.common.response.CommonResponse;
import cn.ch.train.common.response.PageResult;
import cn.ch.train.business.request.DailyTrainCarriageQueryParam;
import cn.ch.train.business.request.DailyTrainCarriageSaveParam;
import cn.ch.train.business.response.DailyTrainCarriageQueryResult;
import cn.ch.train.business.service.DailyTrainCarriageService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/daily-train-carriage")
public class DailyTrainCarriageAdminController {
    @Autowired
    private DailyTrainCarriageService dailyTrainCarriageService;

    @PostMapping("/save")
    public CommonResponse save(@Valid @RequestBody DailyTrainCarriageSaveParam param) {
        dailyTrainCarriageService.save(param);
        return new CommonResponse<>();
    }

    @GetMapping("/query-list")
    public CommonResponse<PageResult<DailyTrainCarriageQueryResult>> queryList(@Valid DailyTrainCarriageQueryParam param) {
        PageResult<DailyTrainCarriageQueryResult> dailyTrainCarriageList = dailyTrainCarriageService.queryList(param);
        return new CommonResponse<>(dailyTrainCarriageList);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResponse delete(@PathVariable Long id) {
        dailyTrainCarriageService.delete(id);
        return new CommonResponse<>();
    }

}
